// custom-tab-bar/index.js
import mys_svg from '@/resource/tabbar/mys.svg'
import my_svg from '@/resource/tabbar/my.svg'
import index_svg from '@/resource/tabbar/index.svg'
import indexs_svg from '@/resource/tabbar/indexs.svg'
import scan_svg from '@/resource/tabbar/scan.svg'
Component({
  data: {
    color: "#888888",
    selectedColor: "#3C6DF0",
    backgroundColor: "#ffffff",
    selected: 0,
    list: [
      {
        pagePath: "/pages/index/index",
        text: "首页",
        iconPath: index_svg,
        selectedIconPath: indexs_svg,
      },
      {
        pagePath: "/pages/scan/index",
        bulge: true,
        text: "",
        iconPath: scan_svg,
        selectedIconPath: scan_svg,
      },
      {
        pagePath: "/pages/my/index",
        text: "我的",
        iconPath: my_svg,
        selectedIconPath: mys_svg,
      },
    ],
  },
  attached() {  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset;
      if (data.index == 1) {
        wx.scanCode({
          success: (res) => {
            console.log(res);
          },
          fail:(err)=>{
            console.log(err)
          }
        });
      } else {
        const url = data.path;
        wx.switchTab({ url });
      }
    },
  }
});
